<?php

namespace app\demo\controller;

use app\BaseController;
use app\common\business\Demo;
use app\common\lib\Snowflake;


class Index extends BaseController
{
    public function index()
    {
        $categoryId = $this->request->param("category_id", 0, "intval");
        if (empty($categoryId)) {
            return show(config("status.error"), "参数错误");
        }

        $demo = new Demo();
        $datas = $demo->getDemoDateByCategoryId($categoryId);

        return show(config("status.sussess"), "ok", $datas);

    }

    public function hello()
    {
        return time();
    }

    public function test()
    {
        $workId = rand(1, 1023);
        $orderID = Snowflake::getInstance()->setWorkId($workId)->Id();

        dump($orderID);
        exit();
    }
}
